/*
 * Copyright (C) 2011 TopCoder Inc., All Rights Reserved.
 */
package gov.nasa.pds.services.impl;

import static org.junit.Assert.assertEquals;

import gov.nasa.pds.services.AdHocQueryTranslator;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import junit.framework.JUnit4TestAdapter;

/**
 * <p>
 * The unit test of {@link AdHocQueryTranslatorImpl} class.
 * </p>
 *
 * @author TCSASSEMBLER
 * @version 1.0
 */
public class AdHocQueryTranslatorImplTest {
    /**
     * The application context for test.
     */
    private ApplicationContext context;

    /**
     * The adHocQuery translator for test.
     */
    private AdHocQueryTranslator adHocQueryTranslator;

    /**
     * Adapter for JUnit 3.
     * @return a test suite.
     */
    public static junit.framework.Test suite() {
        return new JUnit4TestAdapter(AdHocQueryTranslatorImplTest.class);
    }

    /**
     * Sets up the unit tests.
     *
     * @throws Exception to JUnit.
     */
    @Before
    public void setUp() throws Exception {
        context = new ClassPathXmlApplicationContext("beans.xml");
        adHocQueryTranslator = (AdHocQueryTranslator) context.getBean("adHocQueryTranslator");
    }

    /**
     * Test method <code>translateQuery(String adHocQuery)</code>.
     * @throws Exception to JUnit.
     */
    @Test
    public void testTranslateQuery() throws Exception {
        String adHocQuery = "adHocQuery";
        assertEquals("result should be correct", adHocQuery,
                adHocQueryTranslator.translateQuery(adHocQuery));
    }
}
